﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace EdexApiClient.api.v2
{
    public partial class EdexApiContext
    {
        public string ApiUri { get; set; }
        public string RootUri { get; set; }

        private string email { get; set; }
        private string password { get; set; }
        public string api_key { get; set; }

        public EdexApiContext()
        {
            this.ApiUri = System.Configuration.ConfigurationManager.AppSettings["ApiUri"];
            this.RootUri = System.Configuration.ConfigurationManager.AppSettings["RootUri"];
        }

        public EdexApiContext(string apiUri, string rootUri, string email, string password)
        {
            this.ApiUri = apiUri;
            this.RootUri = rootUri;

            this.email = email;
            this.password = password;

            var data = this.GetSession(email, password).Result;
            this.api_key = data.Data.FirstOrDefault().API_KEY;
        }

        public EdexApiContext(string email, string password)
        {
            this.ApiUri = System.Configuration.ConfigurationManager.AppSettings["ApiUri"];
            this.RootUri = System.Configuration.ConfigurationManager.AppSettings["RootUri"];

            this.email = email;
            this.password = password;

            var data = this.GetSession(email, password).Result;
            this.api_key = data.Data.FirstOrDefault().API_KEY;
        }

        public EdexApiContext(string api_key)
        {
            this.ApiUri = System.Configuration.ConfigurationManager.AppSettings["ApiUri"];
            this.RootUri = System.Configuration.ConfigurationManager.AppSettings["RootUri"];

            var data = this.GetSession(api_key).Result;
            this.api_key = api_key;
        }
    }
}
